<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      //defineProperty 控制增删，枚举
      const person = { name: 'lisi' };

      Object.defineProperty(person, 'age', {
        value: 20,
        writable:true,  //默认为false，只读，修改需改为true
        enumerable:true, //可以枚举，for...in
        configurable:true,
      });
      person.hobby = 'xixi'
      person.age = 21
      for(let k in person){
        console.log(k)
      }
    // for (let k in person) {
    //     console.log(k)
    //   }
    delete person.age
      console.log(person);
    </script>
  </body>
</html>
